import {axios} from '@/utils/request'
import qs from "qs"

/**
 * 接口请求统一入口
 * @param url
 * @param params
 * @param config 配置, {Object | String} urlName: 接口名称; showLoading: 是否显示loading, 默认显示; loadingMsg: loading时的提示, 默认'加载中'
 * @return {AxiosPromise<any>}
 */
export function postAction(url, params, config){
  let conf = {}
  if(typeof config === 'string'){
    conf.urlName = config
  }else{
    conf = config
  }
  return axios.post(url,params,conf)
}

export function postActionForm(url, params){
  return axios({
    url,
    method: "post",
    data: qs.stringify(params),
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
    }
  })
}
